package com.obradovicnjegovan.webprodavnica.so.impl;

import org.apache.tapestry5.ioc.annotations.Inject;

import com.obradovicnjegovan.webprodavnica.dao.HibernateDao;
import com.obradovicnjegovan.webprodavnica.entities.Narudzbenica;
import com.obradovicnjegovan.webprodavnica.entities.StatusNarudzbenice;
import com.obradovicnjegovan.webprodavnica.so.PonistiNarudzbenicu;

public class PonistiNarudzbenicuImpl implements PonistiNarudzbenicu{
	@Inject
	private HibernateDao hibernateDao;
	private Narudzbenica narudzbenica;
	public Narudzbenica getNarudzbenica() {
		return narudzbenica;
	}
	public void setNarudzbenica(Narudzbenica narudzbenica) {
		this.narudzbenica = narudzbenica;
	}
	public HibernateDao getHibernateDao() {
		return hibernateDao;
	}
	public void setHibernateDao(HibernateDao hibernateDao) {
		this.hibernateDao = hibernateDao;
	}
	public Object execute() {
		try {
			getNarudzbenica().setStatusNarudzbenice(StatusNarudzbenice.ponistena);
			hibernateDao.save(getNarudzbenica());
			return "Uspesno ponistena narudzbenica";
		} catch (Exception e) {
			return "Sistemska greska. Neuspesno ponistena narudzbenica. Problem: "+e;
		}
	}
	
}
